package com.longtop.leaning.entity;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.Date;

import com.longtop.leaning.util.Base64;

public class FlightData {

    private int id;

    private String fltno;

    private Date fltdate;

    private Date arrdate;

    private Date realfltdate;

    private Date realarrdate;

    private String start;

    private String end;

    private int fltstatus;

    private String fltnotes;

    private String notes;

    

    public int getId() {

       return id;

    }

    public void setId(int id) {

       this.id = id;

    }

    public String getFltno() {

       return fltno;

    }

    public void setFltno(String fltno) {

       this.fltno = fltno;

    }

    public Date getFltdate() {

       return fltdate;

    }

    public void setFltdate(Date fltdate) {

       this.fltdate = fltdate;

    }

    public Date getArrdate() {

       return arrdate;

    }

    public void setArrdate(Date arrdate) {

       this.arrdate = arrdate;

    }

    public Date getRealfltdate() {

       return realfltdate;

    }

    public void setRealfltdate(Date realfltdate) {

       this.realfltdate = realfltdate;

    }

    public Date getRealarrdate() {

       return realarrdate;

    }

    public void setRealarrdate(Date realarrdate) {

       this.realarrdate = realarrdate;

    }

    public String getStart() {

       return start;

    }

    public void setStart(String start) {

       this.start = start;

    }

    public String getEnd() {

       return end;

    }

    public void setEnd(String end) {

       this.end = end;

    }

    public int getFltstatus() {

       return fltstatus;

    }

    public void setFltstatus(int fltstatus) {

       this.fltstatus = fltstatus;

    }

    public String getFltnotes() {

       return fltnotes;

    }

    public void setFltnotes(String fltnotes) {

       this.fltnotes = fltnotes;

    }

    public String getNotes() {

       return notes;

    }

    public void setNotes(String notes) {

       this.notes = notes;

    }

    

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    

    public static Object deserialize(byte[] data) {

       ByteArrayInputStream bais = new ByteArrayInputStream(data);

       DataInputStream dis = new DataInputStream(bais);

       FlightData result = new FlightData();

       try {

           result.setId(dis.readInt());

           result.setFltno(dis.readUTF());

           result.setFltdate(new Date(dis.readLong()));

           result.setArrdate(new Date(dis.readLong()));

           result.setRealfltdate(new Date(dis.readLong()));

           result.setRealarrdate(new Date(dis.readLong()));

           result.setStart(dis.readUTF());

           result.setEnd(dis.readUTF());

           result.setFltstatus(dis.readInt());

           result.setFltnotes(dis.readUTF());

           result.setNotes(dis.readUTF());

           dis.close();

           bais.close();

       } catch (Exception e) {

           e.printStackTrace();

       }

       return result;

    }

    /*
	 * 进行反编码并返回解析后的对像实例(non-Javadoc)
	 * @see com.onest.xmair.serializable.ISerializable#decode(java.lang.String)
	 * Create by haicao
	 * 2009-7-5
	 */
	public static Object decode(String code) {
		byte[] decode = null;
		decode = Base64.decode(code);
		return deserialize(decode);
	}
}